<?php
$nameAll = "";
if ($this->itemType) {
    foreach ($this->typeName as $key => $name) {
        if ($key != 0 && ($this->itemType & $key) == $key) {
            $nameAll = $nameAll . $name[0] . '/';
        }
    }
} else {
    $nameAll = "正常";
}
?>
<table>
    <tr>
        <th class="kd1">快递方式选择<?= $this->formHidden('newAddressId', $this->newAddressId) ?></th>
        <th class="kd2">受理情况</th>
        <th class="kd3">按体积重量</th>
        <th class="kd4">结算重量</th>
        <th class="kd5">预计天数</th>
        <th class="kd6">金额(￥)</th>
    </tr>
    <?php
    $showItem = function($item, $view,$nameAll) {
                $accept = true;
                $message = '';
                $itemAccept =$item->isAccept($view->itemType);
                if((!$itemAccept) && !strpos($message,$nameAll)){
                    $message .= ' 不接受'.$nameAll;
                }
                $accept = $accept && $itemAccept;
                //如果大于2000，Air不接受
//                            if($item->Express->Id == Application_Model_Express::Express_AIR && $view->SumWeight > 2000){
                if ($item->Express->subsequentWeight == 100 && $view->SumWeight > 2000) {
                    $accept = FALSE;
                    $message .= ' 不接受大于2000克的包裹';
                }
                if (strpos('-' . $item->Express->Name, 'EMS') && $view->SumWeight > 30000) {
                    $accept = FALSE;
                    $message .= ' 不接受大于30KG的包裹';
                }
                ?>
                <tr>
                    <td class="kd1">
                        <label>
                            <input data="<?= $item->Express->ReportFee ?>" type="radio" <?= $accept ? '' : ' disabled="disabled"' ?> class="shiptyperadio" value="<?= $item->ExpressId ?>" name="shipType" />
                            <span><?= $item->getExpress()->Name ?></span></label>
                    </td>
                    <td class="kd2"><?= $message ? "<span>$message</span>" : '可受理' ?></td>
                    <td class="kd3"><?= $item->Express->IsVolume ? '<span class="shi">是</span>' : '<span class="fou">否</span>' ?></td>
                    <td class="kd4"><?= $item->Express->IsVolume && $view->volumeWeight > $view->SumWeight ? $view->volumeWeight : $view->SumWeight ?>g</td>
                    <td class="kd5"><?= $item->times ?><input type="hidden" id="isRemoteFee" name="isRemoteFee" value="<?php echo $item->Express->IsRemoteFee;?>" />工作日</td>
                    <td class="kd6"><?= number_format($item->SortKey, 2) ?></td>
                </tr>
            <?php }; ?>
    <?php
    foreach ($this->prices as $item) {
        $weight = 0;
        if ($item->Express->IsVolume && ($this->volumeWeight > $this->SumWeight))
            $weight = $this->volumeWeight;
        else
            $weight = $this->SumWeight;
        $item->SortKey = $item->getMoneyByweight($weight);
    }
    $prices = Uuch_Util::quickSort($this->prices, 'SortKey');
    $air = NULL;
    foreach ($prices as $item) {
        if($item->ExpressId == Application_Model_Express::Expredd_ReceiveUser){
            continue;
         }
         //被禁止
        if($item->Express->isDisable == 1){ 
            continue;
        }
        //东西马
        if($this->isEast){
            if($item->ExpressId == Application_Model_Express::Express_WesternA || $item->ExpressId == Application_Model_Express::Express_WesternB){
                continue;
            }
        } else {
            if($item->ExpressId == Application_Model_Express::Express_EastA || $item->ExpressId == Application_Model_Express::Express_EastB){
                continue;
            }
        }
        if($item->Express->MaxWeight == 2000){
            continue;;
        }
        $showItem($item, $this,$nameAll);
    }
    foreach($prices as $item){
        //因为香港小包最近延误太久，先关掉
         if($item->ExpressId ==  Application_Model_Express::Expredd_ReceiveUser){
             continue;
         }
         //被禁止
         if($item->Express->isDisable == 1){ 
             continue;
         }
        if($item->Express->MaxWeight == 2000){
            $showItem($item,$this,$nameAll);       
        }
    }
    ?>
</table>
<h4><i></i>温馨提示：选择中邮小包运送周期长、丢包率高、物流跟踪不畅，如急用或贵重物品请慎重选择！并且近期联邦爆仓严重，大部分包裹均有延迟1一2周左右，请您慎选，谢谢！</h4>
<?php echo $this->formHidden('isEuro2', $this->city->isEuro()); ?>
<?php echo $this->formHidden('isZipRemoteFee2',$this->isZipRemoteFee); ?>